<?php
require_once 'init-ise.php';
try {
	// try to auth a non existing user
	print "\nInvalid authentication:". authSafe("-1", "test");
	// invalid password
	print "\nInvalid password:". authSafe("1"," ");
	// invalid username
	print "\nInvalid username:". authSafe(" ","password");
	// valid auth
	print "\nValid Authentication:".authSafe("1","pw");
	// valid auth with whitespace
	print "\nValid Auth Whitespace:".authSafe(" 1 ","pw");
	// change user
	$customer = CustomerQuery::create()->findPk("2");
	$new = Auth::update($customer, "usertest", "meinpw");
	print "\nUpdated authentication:". authSafe("usertest","meinpw");
} catch (Exception $e) {
	print $e;
}

function authSafe($name,$pw) {
	try {
		return Auth::check($name,$pw);
	} catch (Exception $e) {
		return "\nERROR:".$e->getMessage();
	}
}
?>